<template>
  <t-base-table hover stripe bordered tableLayout="auto" row-key="index" :data="data" :columns="columns"></t-base-table>
</template>

<script lang="ts" setup>
import type { TableProps } from 'tdesign-vue-next'
import { onMounted, ref } from 'vue'
import axios from 'axios'
const columns = ref<TableProps['columns']>([
  { colKey: 'level', title: '日志等级' },
  { colKey: 'data', title: '详细信息' },
  { colKey: 'timestamp', title: '时间' },
])

const data = ref<TableProps['data']>([])

onMounted(() => {
  axios.get('/api/log')
    .then((response) => {
      response.data.forEach((element: any) => {
        element.timestamp = (new Date(element.timestamp*1000)).toLocaleString()
      })
      data.value = response.data as any
    }).catch((error) => {
      console.error('[Log]Error Getting Log: ', error)
    })
})

</script>

<style scoped></style>
